package cn.client.ui.components

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ListItem
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import cn.client.R
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ModalBottomSheet(

){
    val sheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden)
    val coroutineScope = rememberCoroutineScope()
    ModalBottomSheetLayout(
        sheetState = sheetState,
        sheetContent = {
            //这里显示底部弹窗内容
            ListItem(
                text = { Text("分享动态") },
                icon = {
                    Icon(
                        painterResource(R.drawable.ic_share),
                        null,
                        tint = Color.White,
                        modifier = Modifier.padding(4.dp)
                    )
                },
                modifier = Modifier.clickable {
                    /* TODO: 跳转编辑动态页面 */
                }
            )
        }
//        content = {
//            //处理后退事件，显示和隐藏必须用协程执行
//            BackHandler(sheetState.isVisible) {
//                coroutineScope.launch {
//                    sheetState.hide()
//                }
//            }
//            //显示页面内容
//        }
    ){

    }
}